
<style type="text/css" >
    #swfupload-control p{ margin:10px 5px; font-size:0.9em; }
    #log{ margin:0; padding:0; width:500px;}
    #log li{ list-style-position:inside; margin:2px; border:1px solid #ccc; padding:10px; font-size:12px;
             font-family:Arial, Helvetica, sans-serif; color:#333; background:#fff; position:relative;}
    #log li .progressbar{ border:1px solid #333; height:5px; background:#fff; }
    #log li .progress{ background:#999; width:0%; height:5px; }
    #log li p{ margin:0; line-height:18px; }
    #log li.success{ border:1px solid #339933; background:#ccf9b9; }
    #log li span.cancel{ position:absolute; top:5px; right:5px; width:20px; height:20px;
                         background:url('<{$APPLICATION_URL}>/Themes/Default/Scripts/swfupload/cancel.png') no-repeat; cursor:pointer; }


    #money_table table {
        -moz-border-bottom-colors: none;
        -moz-border-image: none;
        -moz-border-left-colors: none;
        -moz-border-right-colors: none;
        -moz-border-top-colors: none;
        border-bottom-color: #D6D6D6;
        border-bottom-style: solid;
        border-bottom-width: 1px;
        border-collapse: collapse;
        border-left-color-ltr-source: physical;
        border-left-color-rtl-source: physical;
        border-left-color: #D6D6D6;
        border-left-style-ltr-source: physical;
        border-left-style-rtl-source: physical;
        border-left-style: solid;
        border-left-width-ltr-source: physical;
        border-left-width-rtl-source: physical;
        border-left-width: 1px;
        border-right-color-ltr-source: physical;
        border-right-color-rtl-source: physical;
        border-right-color: #D6D6D6;
        border-right-style-ltr-source: physical;
        border-right-style-rtl-source: physical;
        border-right-style: solid;
        border-right-width-ltr-source: physical;
        border-right-width-rtl-source: physical;
        border-right-width: 1px;
        border-top-color: #D6D6D6;
        border-top-style: solid;
        border-top-width: 1px;
    }
    #money_table table {
        border-collapse: collapse;
    }
    #money_table table th {
        background-color: #DDDDDD;
        border-bottom-width: 0;
        border-left-width-ltr-source: physical;
        border-left-width-rtl-source: physical;
        border-left-width: 0;
        border-right-width-ltr-source: physical;
        border-right-width-rtl-source: physical;
        border-right-width: 0;
        border-top-width: 0;
        padding-bottom: 3px;
        padding-left: 10px;
        padding-right: 10px;
        padding-top: 3px;
    }

    table th {
        font-size: 1.2em;
        font-weight: 700;
        padding-left: 5px;
    }

    caption, th {
        text-align: left;
    }

    #money_table table td {
        background-color: #F4F4F4;
        border-right-color-ltr-source: physical;
        border-right-color-rtl-source: physical;
        border-right-color: #D6D6D6;
        border-right-style-ltr-source: physical;
        border-right-style-rtl-source: physical;
        border-right-style: solid;
        border-right-width-ltr-source: physical;
        border-right-width-rtl-source: physical;
        border-right-width: 1px;
        padding-bottom: 5px;
        padding-left: 10px;
        padding-right: 10px;
        padding-top: 5px;
        vertical-align: top;
        width: 160px;
    }
    #money_table .editable .amount {
        display: block;
        float: left;
        font-style: italic;
        position: relative;
        width: 66px;
    }

    #money_table .amount {
        font-size: 14px;
        font-weight: bold;
        line-height: 26px;
        margin-right: 15px;
    }
    #money_table #retail_value .field.deal_template_retail_value {
        display: block;
        position: relative;
    }

    #money_table #retail_value div {
        font-size: 14px;
        line-height: 26px;
    }

    .right_column .text {
        margin-bottom: 0;
        margin-left: 0;
        margin-right: 5px;
        margin-top: 0;
    }
    #money_table #retail_value .field.deal_template_retail_value input {
        padding-left: 15px;
    }

    #money_table .percent {
        font-size: 14px;
        line-height: 26px;
    }
    #money_table .editable .amount input {
        padding-left: 15px;
        width: 55px;
    }

</style>


<style ttype=""text/css">
	.main_column{
		margin-right: 10px;
	}
	.forms li{
		list-style: none;
	}
</style>
<{if $bError}>
<div class="error">
	
	<ul>
		<{foreach from=$aError item=item}>
			<li><{$item}></li>
		<{/foreach}>
	</ul>
	<a title="Click to Close" class="close_notification" href="#"><img height="6" width="6" alt="Close" src="http://localhost/luanvan/Code/Themes/Default/Images/close_icon.gif"></a>
</div>
<{/if}>
<div class="panes_vertical">
    <div class="box">
        <form method="post" action="<{$APPLICATION_URL}>/Admin/Groupon/add" name="frmForm" enctype="multipart/form-data">
            <fieldset>
                <legend>Tao Moi Groupon</legend>
                <!-- <div id="money_table">
                    <table>
                        <thead>
                            <tr>
                                <th>Gia Goc</th>
                                <th>Gia Giam</th>
                                <th>Tien Tra Cho NCC</th>
                                <th>Phi</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td id="retail_value" class="editable">
                                    <span class="amount">
                                        <div class="field deal_template_retail_value text">
                                            <input onkeyup="culCheap(this.value,'retail');" type="text" value="<{if isset($original_price) && $original_price}><{$original_price}><{else}>20000<{/if}>" style="width:90px" size="30" name="original_price" id="deal_template_retail_value" class="prompting_field numerical input"></div>
                                    </span>
                                </td>
                                <td id="customer_discount" data-depends_on="#merchant_margin" class="editable">
                                    <span class="amount">
                                        <div class="field deal_template_customer_discount text">
                                            <input onkeyup="culCheap(this.value,'discount');" type="text" value="10000" size="" name="customer_discount" id="deal_template_customer_discount" class="prompting_field numerical input"></div>
                                    </span>
                                    <span class="percent">50%</span>
                                </td>
                                <td id="merchant_margin" data-depends_on="#customer_discount" class="editable">
                                    <span class="amount">
                                        <div class="field deal_template_merchant_margin text">
                                            <input onkeyup="culCheap(this.value,'merchant');" type="text" value="" size="30" name="merchant_margin" id="deal_template_merchant_margin" class="prompting_field input"></div>
                                    </span>
                                    <span class="percent">25%</span>
                                </td>
                                <td id="groupon_margin" data-percent="0.25" data-amount="5.0" class="last">
                                    <span class="amount">
                                        <span class="value">1000</span>
                                    </span>
                                    <span class="percent">5%</span>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                -->
                <p>
                    <label>Giá gốc:</label>
                    <input type='text' id='original_price' name='original_price' value='<{$original_price}>' class="textfield" style="width: 30%;" max-length="255">
                </p>
                <p>
                    <label>Giá bán:</label>
                    <input type='text' id='sale_price' name='sale_price' value='<{$sale_price}>' class="textfield" style="width: 30%;" max-length="255">
                </p>
                <p>
                    <label>Nhà cung cấp:</label>
                    <select name="supplier_id" id="supplier_id">
                        <option value=''>-- Chọn --</option>
                        <{foreach name=outer item=item from=$arrSupList}>
                        <option value="<{$item->id}>" <{if $supplier == $item->id}> selected="selected" <{/if}>><{$item->supplier_name}></option>
                        <{/foreach}>
                    </select>
                </p>
                <p>
                    <label>Tên:</label>
                    <input type='text' id='groupon_name' name='groupon_name' value='<{$groupon_name}>' class="textfield" style="width: 50%;" max-length="255">
                </p>
                
                <p>
                    <label>Tiêu đề:</label>
                    <input type='text' id='title' name='title' value='<{$title}>' class="textfield" style="width: 50%;" max-length="255">
                </p>
                <p>
                    <label>Thể loại:</label>
                    <select name="category_id" id="category_id">
                        <option value=''>-- Chọn --</option>
                        <{foreach name=outer item=cat from=$arrCatList}>
                        <option value="<{$cat->id}>" <{if $category == $cat->id}> selected="selected" <{/if}>><{$cat->name}></option>
                        <{/foreach}>
                    </select>
                </p>
                <p>
                    <label>Giới thiệu:</label>
                    <textarea name="description" id="description" cols="20" rows="5"><{$description}></textarea>
                </p>
                <p>
                    <label>Điểm nổi bật:</label>
                    <textarea name="hightlight" id="hightlight" cols="20" rows="5"><{$hightlight}></textarea>
                </p>
                <p>
                    <label>Điều kiện mua hàng:</label>
                    <textarea name="fine_print" id="fine_print" cols="20" rows="5"><{$fine_print}></textarea>
                </p>
                <p>
                    <label>Bình luận:</label>
                    <textarea style="width: 50%;" name="comment" id="comment" class="notfck" cols="10" rows="5"><{$comment}></textarea>
                </p>	
                <p>
                <label>Địa điểm:</label>
                    <select style="width: 440px !important;" size="10" id="addressnotadd" multiple="" >
                       <{foreach from=$listAddress item=item}>
                       		<option value="<{$item->id}>"><{$item->name}></option>
                       <{/foreach}>
                    </select>
                </p>
                <p>
                    <a id="btnEditAdd"  href='javascript:;' onclick="addAddIntoEdit()"><button type="button" >Sửa</button></a>                    
                    <a id="addaddress_url" href="#addaddress_form"><button type="button" >Thêm</button></a>
                    <button style="background-image: url(<{$APPLICATION_URL}>/Themes/Default/Images/iconmuiten.jpg);background-position: -14px 50%;height: 19px;" type="button" onclick="addRelated();" class="icondown"></button>
                    <button style="background-image: url(<{$APPLICATION_URL}>/Themes/Default/Images/iconmuiten.jpg);background-position: 0px 50%;height: 19px;" type="button" onclick="removeRelated();" class="iconup"></button>
                </p>

                <p>
                    <select style="width: 440px;" size="10" id="addressadded" multiple="multiple">
                        
                    </select>
                </p>
                <div id="address_related">
                    
                </div>
                <p>
                    <!-- <label>Upload anh:</label>
                <div id="swfupload-control">
                    <input type="button" id="button123" />
                    <p id="queuestatus" ></p>
                    <ol id="log"></ol>
                </div>-->
                <label>Ảnh chính:</label>
                <input type="file" name="picture">

                </p>
                <p>
                    <label>Số lượng bán tối thiểu:</label>
                    <input type='text' id='min_bought' name='min_bought' value='<{$min_bought}>' class="textfield" style="width: 25%;" max-length="255">
                </p>
                <p>
                    <label>Số lượng bán tối đa:</label>
                    <input type='text' id='max_bought' name='max_bought' value='<{$max_bought}>' class="textfield" style="width: 25%;" max-length="255">
                </p>
                <p>
                    <label>Thời gian bán:</label>
                    <input type='text' id='duration' name='duration' value='<{$duration}>' class="textfield" style="width: 25%;" max-length="255">
                    (h)
                </p>
                <p>
                    <input type="button" name="save" class="button" id="save" value=" Thêm " onclick="formSubmit();" />
                    <input type="reset" name="reset" class="button" id="reset" value=" Reset " />
                    <input type="hidden" id="actionForm" name="actionForm" value=""/>
                    <input type="hidden" id="actionKey" name="actionKey" value="<{$actionKey}>" />
                </p>
            </fieldset>
        </form>
    </div>
</div>

<script type="text/javascript">
    //$addressadded : array : storage address value into array
    var addressadded = new Array();
    function formSubmit()
    {
        var theform = document.frmForm;
        theform.actionForm.value = 'submit';
        theform.submit();
        return true;
    }
    function culCheap(value,type){
        var perCustomer_discount=$('#customer_discount .percent').html();
        var perMerchant_margin=$('#merchant_margin .percent').html();
        var perGroupon_margin=$('#groupon_margin .percent').html();

        var valRetail_value=parseFloat($('#retail_value input').val());
        var valCustomer_discount=parseFloat($('#customer_discount input').val());
        var valMerchant_margin=parseFloat($('#merchant_margin input').val());

        var valGroupon_margin=$('#groupon_margin .value').html();
        var valGroupon_margin = parseFloat(valGroupon_margin.toString());
        switch (type) {
            case 'retail':
                $('#customer_discount input').attr("value",value * parseInt(perCustomer_discount) *0.01 );
                $('#merchant_margin input').attr("value",value * parseInt(perMerchant_margin) *0.01);
                $('#groupon_margin .value').html(value * parseInt(perGroupon_margin) *0.01);
                break;
            case 'discount':
                $('#customer_discount .percent').html( (value / valRetail_value * 100)+'%'  );
                valMerchant_margin=valRetail_value - valCustomer_discount - valGroupon_margin;
                $('#merchant_margin input').attr("value", valMerchant_margin);
                $('#merchant_margin .percent').html( (valMerchant_margin / valRetail_value * 100)+'%'  );
                break;
            case 'merchant':
                $('#merchant_margin .percent').html( (value / valRetail_value * 100)+'%'  );
                valCustomer_discount = valRetail_value - valMerchant_margin - valGroupon_margin;
                $('#customer_discount input').attr("value", valCustomer_discount);
                $('#customer_discount .percent').html( (valCustomer_discount / valRetail_value * 100)+'%'  );
                break;
            default:
                break;
        }
        function initValue(){
            var original_price = parseFloat('<{if isset($original_price)}><{$original_price}><{else}>20000<{/if}>');
            var customer_discount = parseFloat('<{if isset($customer_discount)}><{$customer_discount}><{else}>10000<{/if}>');

            var perGroupon_margin=$('#groupon_margin .percent').html();

            $('#customer_discount input').attr("value",customer_discount);
            var perCustomer_discount = customer_discount / original_price * 100;
            $('#customer_discount .percent').html( perCustomer_discount + '%'  );

            var  merchant_marginPercent = 100 -  parseInt(perCustomer_discount) - parseInt(perGroupon_margin);
            $('#merchant_margin input').attr("value",original_price * parseInt(merchant_marginPercent) *0.01);
            $('#merchant_margin .percent').html( merchant_marginPercent +'%'  );

            $('#groupon_margin .value').html((original_price * parseInt(perGroupon_margin) *0.01));
        }
    }
    $(document).ready(function(){

        $("#addaddress_url").fancybox({
			'scrolling'		: 'no',
			'titleShow'		: false,
			'onClosed'		: function() {
			}
		});

        var original_price = parseFloat('<{if isset($original_price) && $original_price}><{$original_price}><{else}>20000<{/if}>');
        var customer_discount = parseFloat('<{if isset($customer_discount) && $customer_discount}><{$customer_discount}><{else}>10000<{/if}>');

        var perGroupon_margin=$('#groupon_margin .percent').html();

        $('#customer_discount input').attr("value",customer_discount);
        var perCustomer_discount = customer_discount / original_price * 100;
        $('#customer_discount .percent').html( perCustomer_discount + '%'  );

        var  merchant_marginPercent = 100 -  parseInt(perCustomer_discount) - parseInt(perGroupon_margin);
        $('#merchant_margin input').attr("value",original_price * parseInt(merchant_marginPercent) *0.01);
        $('#merchant_margin .percent').html( merchant_marginPercent +'%'  );

        $('#groupon_margin .value').html((original_price * parseInt(perGroupon_margin) *0.01));
    });

    function addRelated() {
        jQuery('#addressnotadd :selected').each(function() {
            jQuery(this).remove();
            jQuery('#addressadded option[value=\'' + jQuery(this).attr('value') + '\']').remove();
            jQuery('#addressadded').append('<option value="' + jQuery(this).attr('value') + '">' + jQuery(this).text() + '</option>');
            jQuery('#address_related input[value=\'' + jQuery(this).attr('value') + '\']').remove();
            jQuery('#address_related').append('<input type="hidden" name="address_related[]" value="' + jQuery(this).attr('value') + '" />');
            //add value into addressadded array
            addressadded = addressadded.concat(jQuery(this).attr('value'));
        });
    }

    function removeRelated() {
        jQuery('#addressadded :selected').each(function() {
            jQuery(this).remove();
            jQuery('#addressnotadd option[value=\'' + jQuery(this).attr('value') + '\']').remove();
            jQuery('#addressnotadd').append('<option value="' + jQuery(this).attr('value') + '">' + jQuery(this).text() + '</option>');

            jQuery('#address_related input[value=\'' + jQuery(this).attr('value') + '\']').remove();
            //remove value from addressadded array
            removeByValue(addressadded,jQuery(this).attr('value'));
        });
    }
    //remove an value item of array
    function removeByValue(arr, val) {
        for(var i=0; i<arr.length; i++) {
            if(arr[i] == val) {
                arr.splice(i, 1);
                break;
            }
        }
    }
    function addAddIntoEdit(){

        var href ='<{$APPLICATION_URL}>/Admin/GrouponAddress/edit';
        jQuery('#addressnotadd :selected').each(function() {
            href+='/'+'add_id/'+jQuery(this).attr('value');
            return false;
        });
        if('<{$APPLICATION_URL}>/Admin/GrouponAddress/edit' == href){
            alert('Chọn địa điểm để sửa.');
        }else{
	        $.fancybox({
	    		'scrolling'		: 'no',
	    		'titleShow'		: true,
	        	'href' : href
	    	});
    	}
    }
    function loadAllAddress(){
	 	$.ajax({
			type		: "POST",
			cache	: false,
			dataType: 'json',
			url		: "<{$APPLICATION_URL}>/Admin/GrouponAddress/getall",
			success: function(obj) {
				console.log(obj);
				var str="";
				for(var i = 0; i < obj.length; i++)
	                {	
	                    str += '<option value="'+obj[i]['id']+'">'+obj[i]['name']+'</option>';
	                }
	                jQuery('#addressnotadd').html(str);
			}
		});
    }
    function processAddAddressForm() {		
     	var checkResult = true;
     	var form = document.addaddressForm;
    	
     	if(form)
     	{
    	 	$.ajax({
    			type		: "POST",
    			cache	: false,
    			dataType: 'json',
    			url		: "<{$APPLICATION_URL}>/Admin/GrouponAddress/add",
    			data		: $(".addaddressForm").serializeArray(),
    			success: function(obj) {
    				if (typeof obj["error"] != "undefined" && (obj["error"] == "1" || obj["error"] == 1)) {				
    					$.fancybox.close();
    					loadAllAddress();						
    				}
    				else 
    				{
    					$("#addaddress_error").show();
    					$.fancybox.resize();
    				}
    			}
    		});
    	 	
    		return false;
     	}
    	
     	return false;
    	}
    function in_array(needle, haystack, argStrict) {
        // Checks if the given value exists in the array
        // 
        // *     example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']);    // *     returns 1: true
        // *     example 2: in_array('vlado', {0: 'Kevin', vlado: 'van', 1: 'Zonneveld'});
        // *     returns 2: false
        // *     example 3: in_array(1, ['1', '2', '3']);
        // *     returns 3: true    // *     example 3: in_array(1, ['1', '2', '3'], false);
        // *     returns 3: true
        // *     example 4: in_array(1, ['1', '2', '3'], true);
        // *     returns 4: false
        var key = '', strict = !! argStrict;
        if (strict) {
            for (key in haystack) {
                if (haystack[key] === needle) {
                    return true;
                }
            }
        } else {
            for (key in haystack) {
                if (haystack[key] == needle) {
                    return true;
                }
            }
        }
        return false;
    }
</script>
<script type="text/javascript" src="<{$APPLICATION_URL}>/Libraries/External/fckeditor/fckeditor.js"></script>
<script type="text/javascript">
    <!--
    /*
var sToolbar;
var oFCKeditor = new FCKeditor('news_body');
oFCKeditor.BasePath = "./include/fckeditor/";
var sSkinPath = 'skins/silver/'; 	                  

oFCKeditor.Config["CustomConfigurationsPath"] = "js/blog_fckconfig.js";
oFCKeditor.Config["DefaultLanguage"] = "{$language_code}";
oFCKeditor.Config['AutoDetectLanguage'] = false;
oFCKeditor.Height = "300";
oFCKeditor.Width = "502";
oFCKeditor.ToolbarSet = "se_blog";

oFCKeditor.Config['SkinPath'] = sSkinPath;
oFCKeditor.ReplaceTextarea() ;
//FCKeditor.ReplaceAllTextareas();
     */
    var textareaToEditor = function( textarea )
    {
        var editor = new FCKeditor( textarea.name ) ;

        //editor.Width = Math.max( textarea.offsetWidth, FCKeditor.MinWidth ) ;
        //editor.Height = Math.max( textarea.offsetHeight, FCKeditor.MinHeight ) ;
        editor.BasePath = "<{$APPLICATION_URL}>/Libraries/External/fckeditor/";
        editor.Config["CustomConfigurationsPath"] = "<{$APPLICATION_URL}>/Libraries/External/fckeditor/blog_fckconfig.js";
        editor.Config["DefaultLanguage"] = "en";
        editor.Config['AutoDetectLanguage'] = false;
        editor.Height = "400";
        editor.Width = "80%";
        //editor.ToolbarSet = "se_blog";

        editor.Config['SkinPath'] = 'skins/silver/';
        return editor ;
    };

    FCKeditor.ReplaceAllTextareas = function()
    {
        var textareas = document.getElementsByTagName( 'textarea' ) ;

        for ( var i = 0 ; i < textareas.length ; i++ )
        {
            var editor = null ;
            var textarea = textareas[i] ;
            var name = textarea.name ;
			if($('#'+textarea.id).attr('class') == 'notfck') continue;
            // The "name" attribute must exist.
            if ( !name || name.length == 0 )
                continue ;

            if ( typeof arguments[0] == 'string' )
            {
                // The textarea class name could be passed as the function
                // parameter.

                var classRegex = new RegExp( '(?:^| )' + arguments[0] + '(?:$| )' ) ;

                if ( !classRegex.test( textarea.className ) )
                    continue ;
            }
            else if ( typeof arguments[0] == 'function' )
            {
                // An assertion function could be passed as the function parameter.
                // It must explicitly return "false" to ignore a specific <textarea>.
                editor = textareaToEditor( textarea ) ;
                if ( arguments[0]( textarea, editor ) === false )
                    continue ;
            }

            if ( !editor )
                editor = textareaToEditor( textarea ) ;

            editor.ReplaceTextarea() ;
        }
    };
    FCKeditor.ReplaceAllTextareas();
    //-->
</script>
<script type="text/javascript">
    //$(function(){
    $('#swfupload-control').swfupload({
        upload_url: "<{$APPLICATION_URL}>/Admin/Groupon/upphoto",
        file_post_name: 'uploadfile',
        file_size_limit : "200000",
        file_types : "*.jpg;*.png;*.gif",
        file_types_description : "Image files",
        file_upload_limit : 5,
        flash_url : "<{$APPLICATION_URL}>/Themes/Default/Scripts/swfupload/swfupload.swf",
        button_image_url : '<{$APPLICATION_URL}>/Themes/Default/Scripts/swfupload/wdp_buttons_upload_114x29.png',
        button_width : 114,
        button_height : 29,
        button_placeholder : $('#button123'),
        debug: false
    })
    .bind('fileQueued', function(event, file){
        var listitem='<li id="'+file.id+'" >'+
            'File: <em>'+file.name+'</em> ('+Math.round(file.size/1024)+' KB) <span class="progressvalue" ></span>'+
            '<div class="progressbar" ><div class="progress" ></div></div>'+
            '<p class="status" >Pending</p>'+
            '<span class="cancel" >&nbsp;</span>'+
            '</li>';
        $('#log').append(listitem);
        $('li#'+file.id+' .cancel').bind('click', function(){
            var swfu = $.swfupload.getInstance('#swfupload-control');
            swfu.cancelUpload(file.id);
            $('li#'+file.id).slideUp('fast');
        });
        // start the upload since it's queued
        $(this).swfupload('startUpload');
    })
    .bind('fileQueueError', function(event, file, errorCode, message){
        alert('Size of the file '+file.name+' is greater than limit');
    })
    .bind('fileDialogComplete', function(event, numFilesSelected, numFilesQueued){
        $('#queuestatus').text('Files Selected: '+numFilesSelected+' / Queued Files: '+numFilesQueued);
    })
    .bind('uploadStart', function(event, file){
        $('#log li#'+file.id).find('p.status').text('Uploading...');
        $('#log li#'+file.id).find('span.progressvalue').text('0%');
        $('#log li#'+file.id).find('span.cancel').hide();
    })
    .bind('uploadProgress', function(event, file, bytesLoaded){
        //Show Progress
        var percentage=Math.round((bytesLoaded/file.size)*100);
        $('#log li#'+file.id).find('div.progress').css('width', percentage+'%');
        $('#log li#'+file.id).find('span.progressvalue').text(percentage+'%');
    })
    .bind('uploadSuccess', function(event, file, serverData){
        var item=$('#log li#'+file.id);
        item.find('div.progress').css('width', '100%');
        item.find('span.progressvalue').text('100%');
        var pathtofile='<a href="uploads/'+file.name+'" target="_blank" >view &raquo;</a>';
        item.addClass('success').find('p.status').html('Done!!! | '+pathtofile);
    })
    .bind('uploadComplete', function(event, file){
        // upload has completed, try the next one in the queue
        $(this).swfupload('startUpload');
    })
    //});

</script>

<div style='display: none'>
	<div id="addaddress_form">
		<div id="main-content">
			<div class="two-column alpha">
				<h4 class="article-title">Thêm địa chỉ</h4>
				<form action="<{$APPLICATION_URL}>/Admin/GrouponAddress/add" method="post"
					id="addaddressForm" name="addaddressForm" class="addaddressForm" onsubmit="return processAddAddressForm();">
					<ol class="forms">
						<li>
							<span class="error" id="addaddress_error" style="display: none;">Thêm địa chỉ không thành công.</span>
						</li>
						<li><label for="name">Tên địa chỉ</label><input type="text"
							id="name" name="name" value=""></li>
						<li>
							<select name="city">
								<option value="1">Hồ Chí Minh</option>
								<option value="2">Hà Nội</option>
							</select>
						</li>
						<li><label for="address">Địa chỉ</label> <input type="text"
							id="address" name="address" value="" />
						</li>
						<li><label for="phone">Số điện thoại</label> <input type="text"
							id="phone" name="phone" value="" />
						</li>
						<li>
						<input id="login-form" name="loginButton" type="submit" class="silver-button" value="Thêm" style="width:50px">
						

					</ol>
				</form>
				<div class="clear"></div>
			</div>			
		</div>
	</div>
</div>